﻿<%
dim adminid:adminid=cls.loadsession("adminid")
dim adminname:adminname=cls.loadsession("adminname")
dim penname:penname=cls.loadsession("penname")
dim admingroupid:admingroupid=cls.getint(cls.loadsession("admingroupid"),0)
dim admin_loginpwd:admin_loginpwd=cls.loadcookie("loginpwd")
dim admin_loginkey:admin_loginkey=cls.loadcookie("loginkey")
dim admin_loginbase:admin_loginbase=admin_loginpwd

sub islogin()
	if cls.strlen(adminid)=0 or cls.strlen(adminname)=0 then
		dim t0,t1,t2
		t0=cls.getint(cls.loadcookie("adminid"),0)
		t1=admin_loginpwd
		t2=admin_loginkey
		if cls.strlen(t0)=0 or cls.strlen(t1)=0 or cls.strlen(t2)=0 then
			cls.go "login.asp?act=out"
			exit sub
		else
			dim data
			data=cls.db.dbload(1,"adminid,adminname,adminpass,islock,groupid,penname","[sys_Admin]","adminid="&t0&"","")
			if ubound(data)<0 then
				cls.go "login.asp?act=out"
				exit sub
			else
				if md5(data(1,0)&data(2,0)&t2)<>t1 or data(3,0)=0 then
					cls.go "login.asp?act=out"
					exit sub
				else
					adminid=data(0,0)
					adminname=data(1,0)
					penname=data(5,0)
					cls.setsession "adminid",adminid
					cls.setsession "adminname",adminname
					cls.setsession "penname",penname
					cls.setsession "admingroupid",data(4,0)
				end if
			end if
		end if
	end if
end sub

sub is_plug_login()
	dim t0,t1,t2,t3
	t0=adminid
	t1=admin_loginpwd
	t3=admin_loginkey
	t2="plug_login_failed"
	if cls.strlen(t0)=0 or cls.strlen(t1)=0 then
		cls.echo t2
		cls.die
		exit sub
	end if
end sub

function isuplogin()
	isuplogin=0
	dim t0,t1,t2
	t0=cls.getint(cls.fget("admin_id",0),0)
	t1=cls.fget("loginbase",0)
	t2=admin_loginkey
	if cls.strlen(t0)=0 or cls.strlen(t1)=0 then
		exit function
	end if
	dim data
	data=cls.db.dbload(1,"adminid,adminname,adminpass,islock","sd_admin","adminid="&t0&"","")
	if ubound(data)<0 then
		exit function
	else
		if md5(data(1,0)&data(2,0)&t2)<>t1 or data(3,0)=0 then
			exit function
		end if
	end if
	isuplogin=1
end function
%>